#include "ExchangeDocumentReference.h"
#include "common/constant.h"
#include "ExchangeDocumentInstance.h"
#include "ExchangeTopoShape.h"

AMCAX_EXCHANGE_NAMESPACE_BEGIN

    std::vector<std::shared_ptr<ExchangeDocumentInstance>> ExchangeDocumentReference::GetDirectChildInstances() const 
    {
        return childInstances_;
    }

    void ExchangeDocumentReference::AddChildInstance(std::shared_ptr<ExchangeDocumentInstance> childInstance)
    {
        childInstances_.push_back(childInstance);
    }

    void ExchangeDocumentReference::RemoveChildInstance(std::shared_ptr<ExchangeDocumentInstance> childInstance)
    {
        childInstances_.erase(std::remove(childInstances_.begin(), childInstances_.end(), childInstance), childInstances_.end());
    }

    bool ExchangeDocumentReference::IsPart() const
    {
        return isPart_;
    }

    void ExchangeDocumentReference::SetIsPart(bool isPart)
    {
        isPart_ = isPart;
    }

    std::string ExchangeDocumentReference::GetName() const
    {
        return name_;
    }

    void ExchangeDocumentReference::SetName(const std::string& name)
    {
        name_ = name;
    }

    unsigned int ExchangeDocumentReference::GetId() const
    {
        return id_;
    }

    void ExchangeDocumentReference::SetId(unsigned int id)
    {
        id_ = id;
    }

    bool ExchangeDocumentReference::GetPartShape( std::shared_ptr<ExchangeTopoShape> &topoShape) const
    {
        if(!IsPart())
        {
            return false;
        }
        // topoCompound = partTopoCompound_;
        topoShape = topoShape_ ;
        return true;
    }

    bool ExchangeDocumentReference::SetPartShape(const std::shared_ptr<ExchangeTopoShape> &topoShape)
        {
            if (!IsPart())
            {
                return false;
            }
            // partTopoCompound_ = topoCompound;
            topoShape_ = topoShape ;
            return true;
        }

        bool ExchangeDocumentReference::GetPMIData() const
        {
            // TODO: need to implement.
            return false;
        }

AMCAX_EXCHANGE_NAMESPACE_END